<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
           <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    <%
	String path = request.getContextPath();
	//request.getScheme()：请求协议http，https
	//request.getServerName()：服务器名字：也就是ip地址
	//request.getServerPort()：端口号
	//path：项目路径
	//bashPath=http://localhost/8888/
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
 <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
    <link href="css/reg.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="css/base.css" type="text/css"/>
    <link rel="stylesheet" href="css/headbott.css" type="text/css"/>
    <link rel="stylesheet" href="css/index.css" type="text/css"/>
    <link rel="stylesheet" href="css/ly-list.css" type="text/css"/>
    <link rel="stylesheet" href="css/back.css" type="text/css"/>
    <link rel="stylesheet" href="css/toastr.css" />
<title>Insert title here</title>
</head>
<body>
<div id="header">
    <div class="heade-con">
        <div class="logo"><a href=""><img src="images/LOGO.png"/></a></div>
        <div class="nav posa">
            <ul>
                <li><a href="index.do">首页</a></li>
                <li><a href="gyzc-list.do">公益众筹</a></li>
                <li><a href="cop.do">常见问题</a></li>
                <li><a href="ly-list.do">众筹资讯</a></li>
                <li><a class="vcolor" href="new_product.do" style="">发布项目</a></li>
            </ul>
        </div>
        <div class="search">
            <form action="">
                <input type="text" class="search-txt" value="" placeholder="找项目">
                <input type="submit" class="search-but" value="">
            </form>
        </div>
        <div class="index-login">

            <a href="login.do">登录</a>
            <span style="color: white;">|</span>
            <a href="reg.do">注册</a>

        </div>
    </div>
</div>
<!--中间-->
<div class="product">
    <!--头上表格-->
    <div class="product-table">
        <div class="product-left">
            <table class="table table-bordered">
                <tr class="text-center">
                    <td class="title-td"><a href="new_product.do">基本信息</a></td>
                    <td class="title-td"><a href="new_info.do">项目信息</a></td>
                    <td class="title-td"><a href="new_detail.do">详细描述</a></td>
                    <td class="active title-td"><a href="new_back.do">回报设置</a></td>
                </tr>
            </table>
        </div>
        <div class="product-right">
            <table class="table table-bordered">
                <tr class="text-center">
                    <td class="title-td">预览</td>
                </tr>

            </table>

        </div>
    </div>
    <!--下部foem表单-->
    <div class="product-form">
        <!--上标题-->
        <div class="product-title">
            <div class="my-h4">
                <h4>设置你的回报信息</h4>
            </div>
            <div class="btn-save">
                <button class="btn btn-default" id="btn">保存草稿</button>
            </div>

        </div>
        <div class="clear"></div>
        <hr>
        <!--描述项目-->
		<div>
        <div class="product-title">
            <div class="my-h4">
                <h4><b>回报</b></h4>
            </div>
        </div>
        
        <div class="clear"></div>
        <hr>
        <!--编辑信息表单-->
        <form id="form1">
            <div class="my-form">
                <div class="back">
                    <b>回报类型：</b>
                    <label class="radio-inline">
                        <input type="radio" name="ryType" id="optionsRadios3" value="0" > <b>实物回报(回报需邮寄)</b>
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="ryType" id="optionsRadios4"  value="1" checked> <b>虚拟回报(回报无需邮寄)</b>
                    </label>
                </div>
                <div class="back"><b>支持金额：</b><input id="ryPaymoney" name="ryPaymoney" class="input-mon" placeholder="输入需要用户支持的金额">元</div>
                <div class="back"><b>具体规则：</b>每 <input id="ryRule" name="ryRule" class="input-per" placeholder="此项必填"> 支持者抽出1名中奖者</div>
                <div class="back"><b>回报内容：</b><div><textarea id="ryContent" name="ryContent" rows="2" placeholder="一句话介绍一下你的项目吧"></textarea></div></div>
                <div class="back"><b>人数上限：</b><input id="ryNumber" name="ryNumber" class="input-num" placeholder="0">个<small>"0"为不需要名额</small></div>
                <div class="back"><b>回报时间：</b><input id="ryTime" name="ryTime" class="input-num" placeholder="0">天<small>"0"为开奖后立即发送</small></div>
                <div class="clear"></div>
                <hr>
                <div class="text-center"><button class="btn btn-primary" id="del1">删除</button><button class="btn" id="save1" type="button">保存</button></div><br>
            </div>
        </form>
     	</div>
        
        <div class="text-center"><a  href="javaScript:void(0)" id="btn1">+继续添加新的回报</a></div>
    </div>

</div>
<!--下部-->
<div id="bottom">
    <div class="bottom-ggt"><a href=""><img src="images/bottbom_68.jpg" alt=""/></a></div>
    <div class="zc-yqlink">
        <ul>
            <li><a href="">阿里巴巴集团</a></li>
            <li><a href="">淘宝网</a></li>
            <li><a href="">天猫</a></li>
            <li><a href="">聚划算</a></li>
            <li><a href="">全球速卖通</a></li>
            <li><a href="">阿里巴巴国际交易市场</a></li>
            <li><a href="">1688</a></li>
            <li><a href="">阿里妈妈</a></li>
            <li><a href="">阿里旅行</a></li>
            <li><a href="">阿里云计算</a></li>
            <li><a href="">阿里巴巴集团</a></li>
            <li><a href="">淘宝网</a></li>
            <li><a href="">天猫</a></li>
            <li><a href="">聚划算</a></li>
            <li><a href="">全球速卖通</a></li>
            <li><a href="">阿里巴巴国际交易市场</a></li>
            <li><a href="">1688</a></li>
            <li><a href="">阿里妈妈</a></li>
            <li><a href="">阿里云计算</a></li>
        </ul>
    </div>
    <div class="footer-bd">

        <a href=" ">关于淘宝</a>
        <a href=" ">合作伙伴</a>
        <a href=" ">营销中心</a>
        <a href=" ">廉正举报</a>
        <a href=" ">联系客服</a>
        <a href=" ">开放平台</a>
        <a href=" ">诚征英才</a>
        <a href=" ">联系我们</a>
        <a href=" ">网站地图</a>
        <a href=" ">法律声明</a>　　　
        <em>© 2003-2015 Taobao.com 版权所有</em><br>

        <br>
        <span>网络文化经营许可证：<a href=" ">浙网文[2013]0268-027号</a></span>
        <b>|</b>
        <span data-spm-protocol="i">增值电信业务经营许可证：<a href="">浙B2-20080224-1</a></span>
        <b>|</b>
        <span>信息网络传播视听节目许可证：1109364号</span>
        <b>|</b>
        <span>举报电话:0571-81683755</span>
    </div>
</div>
</body>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/toastr.js"></script>
<script type="text/javascript" src="js/jquery-form.js"></script>
<script type="text/javascript">

	$("#btn").click(function(){
		gogogo();
	})
	$("#save1").click(function(){
		gogogo();
	})
	$("#del1").click(function(){
		$("#form1").parent().empty();
	})
	function gogogo(){
		var radio=document.getElementsByName("ryType");
 	 	var ryType=null;   
	 		for(var i=0;i<radio.length;i++){
       		if(radio[i].checked==true) {
       	 		ryType=radio[i].value;
                  break;
        	}
		 } 
	 		var test_ryPaymoney = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
	 		var test_rul = /^[1-9]\d*$/;
	 		
	 		var ryPaymoney = $("#ryPaymoney").val();
	 		var ryRule = $("#ryRule").val();
	 		var ryContent = $("#ryContent").val();
	 		var ryNumber = $("#ryNumber").val();
	 		var ryTime = $("#ryTime").val();
	 		if(!test_ryPaymoney.test(ryPaymoney)){
	 			toastr.error("请填写正确的支持金额");
	 		}else if(!test_rul.test(ryRule)){
	 			toastr.error("请填写正确的具体规则(非零正整数)");
	 		}else if(ryContent==null||ryContent.trim()==""){
	 			toastr.error("回报不能为空");
	 		}else if(!test_rul.test(ryNumber)){
	 			toastr.error("请填写正确的回报人数(非零正整数)")
	 		}else if(!test_rul.test(ryTime)){
	 			toastr.error("请填写正确的回报时间(非零正整数)")
	 		}else{
	 			$("#form1").ajaxSubmit({
	 				url:"progo4.do",
	 				type:"post",
	 				success:function(data){
	 					if(data=="1"){	
	 						toastr.success("保存成功");
	 						setTimeout(function(){alert("项目发布成功，等待审核。工作人员将会在1-3个工作日完成审核。")},600);
	 						setTimeout(function(){window.location.href="index.do"},600);
	 					}else if (data=="0"){
	 						toastr.error("保存失败,请重试");
	 					}
	 				},
	 				error:function(){
	 					toastr.error("网络繁忙,请稍后再试");
	 				},
	 			})
	 		}
	}

	$("#btn1").click(function(){
		var radio=document.getElementsByName("ryType");
 	 	var ryType=null;   
	 		for(var i=0;i<radio.length;i++){
       		if(radio[i].checked==true) {
       	 		ryType=radio[i].value;
                  break;
        	}
		 } 
	 		var test_ryPaymoney = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
	 		var test_rul = /^[1-9]\d*$/;
	 		
	 		var ryPaymoney = $("#ryPaymoney").val();
	 		var ryRule = $("#ryRule").val();
	 		var ryContent = $("#ryContent").val();
	 		var ryNumber = $("#ryNumber").val();
	 		var ryTime = $("#ryTime").val();
	 		if(!test_ryPaymoney.test(ryPaymoney)){
	 			toastr.error("请填写正确的支持金额");
	 		}else if(!test_rul.test(ryRule)){
	 			toastr.error("请填写正确的具体规则(非零正整数)");
	 		}else if(ryContent==null||ryContent.trim()==""){
	 			toastr.error("回报不能为空");
	 		}else if(!test_rul.test(ryNumber)){
	 			toastr.error("请填写正确的回报人数(非零正整数)")
	 		}else if(!test_rul.test(ryTime)){
	 			toastr.error("请填写正确的回报时间(非零正整数)")
	 		}else{
	 			$("#form1").ajaxSubmit({
	 				url:"progo4.do",
	 				type:"post",
	 				success:function(data){
	 					if(data=="1"){	
	 						toastr.success("保存成功,继续添加回报");
	 						setTimeout(function(){window.location.href="new_back.do"},600);
	 					}else if (data=="0"){
	 						toastr.error("保存失败,请重试");
	 					}
	 				},
	 				error:function(){
	 					toastr.error("网络繁忙,请稍后再试");
	 				},
	 			})
	 		}
	})
	
</script>
</html>